package com.gxuwz.handler;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;

import com.gxuwz.common.Const;

/**
 * 配置登陆失败处理器
 * @author h
 *
 */
public class MyLoginFailHandler implements AuthenticationFailureHandler {

	@Override
	public void onAuthenticationFailure(HttpServletRequest req,
			HttpServletResponse resp,
			AuthenticationException authenticationexception)
			throws IOException, ServletException {
		resp.sendRedirect("login.jsp");
		HttpSession session = req.getSession();
		if (session != null) {
			session.setAttribute("msg", Const.LOGIN_ERROE_MSG);
		}
	}

}
